﻿#include <iostream>
#include <string>
using namespace std;
string pandas_to_american = "你们这群美国国资本家，太可恶了！我永远都不会原谅你们！";
string pandas_to_french = "你们这群法国国资本家，太可恶了！";
string confess_french = "Je suis français et je suis désolé pour toi!";
string confess_american = "I am an American and I am guilty of a heinous crime!";
class Pandas
{
private:
public:
  void recvMessage(const string &msg)
  {
    cout << "pandas get message:" << msg << endl;
  }
  string sendMessage(const string &msg)
  {
    return msg;
  }
};
class AbHuman
{
private:
public:
  virtual string confession() = 0;
  virtual void recvMessage(const string &msg) = 0;
};
class French : public AbHuman
{
private:
public:
  string confession() { return confess_french; }
  void recvMessage(const string &msg)
  {
    cout << "French get message: " << msg << endl;
  }
};
class American : public AbHuman
{
private:
public:
  string confession() { return confess_american; }
  void recvMessage(const string &msg)
  {
    cout << "American get message:" << msg << endl;
  }
};
class AbAdaptor
{
private:
public:
  Pandas pandas;
  AbHuman *human = nullptr;
  AbAdaptor(AbHuman *human_) : human(human_) {}
  virtual ~AbAdaptor() {}
  virtual void transToPandas() = 0;
  virtual void transToHuman() = 0;
};
class AdaptorFrench : public AbAdaptor
{
private:
public:
  using AbAdaptor::AbAdaptor;
  void transToPandas() override
  {
    string confess = human->confession();
    if (confess.compare(confess_french) == 0)
    {
      pandas.recvMessage("来自法国人的消息：我是法国人，我为你感到难过！");
    }
  }
  void transToHuman() override
  {
    string response = pandas.sendMessage(pandas_to_french);
    if (response.compare(pandas_to_french) == 0)
      human->recvMessage("Vous, les capitalistes français, êtes tellement abominables !");
  }
};
class AdaptorAmerican : public AbAdaptor
{
private:
public:
  using AbAdaptor::AbAdaptor;
  void transToPandas() override
  {
    string confess = human->confession();
    if (confess.compare(confess_american) == 0)
      pandas.recvMessage("我是美国人，我犯下了滔天罪行！");
  }
  void transToHuman() override
  {
    pandas.sendMessage(pandas_to_american);
    human->recvMessage("You American capitalists are so abominable! I will never forgive you!");
  }
};
int main()
{
  AbHuman *human = new American();
  AbAdaptor *adaptor = new AdaptorAmerican(human);
  adaptor->transToPandas();
  adaptor->transToHuman();
  cout << "************************************************************************" << endl;
  human = new French();
  adaptor = new AdaptorFrench(human);
  adaptor->transToPandas();
  adaptor->transToHuman();
  return 0;
}